﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpagecuatui.Master" AutoEventWireup="true" CodeBehind="NewsCategories.aspx.cs" Inherits="SQT.tracnghiem.BaiViet.NewsCategories" %>

<%@ Import Namespace="DataAccess" %>
<%@ Register Src="~/BaiViet/Left_searchmenupage.ascx" TagPrefix="uc1" TagName="Left_searchmenupage" %>
<%@ Register Src="~/BaiViet/Right_newestpost.ascx" TagPrefix="uc1" TagName="Right_newestpost" %>
<%@ Register Src="~/BaiViet/Right_hotestpost.ascx" TagPrefix="uc1" TagName="Right_hotestpost" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../Scripts/jssor.slider-21.1.5.mini.js"></script>
    <title><%=this.CateName %> - Tiếng nhật thật dễ</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div class="page-main-content w3-row">
        <div class="news-page w3-padding">
            <div id="news-main-content" class="w3-row">
                <div id="news-menu" class="w3-col l2">
                    <uc1:Left_searchmenupage runat="server" ID="Left_searchmenupage" />
                </div>
                <%
                    var get_top = (from p in new TblNewsController().FetchAll().Where(x => x.NewsCategory == this.cate && x.NewsActive == true && x.NewsDelete == false && x.NewsTop == true) orderby p.NewsDate descending select p).ToList();
                    var get_new_news = (from p in new TblNewsController().FetchAll().Where(x => x.NewsCategory == this.cate && x.NewsActive == true && x.NewsDelete == false) orderby p.NewsDate descending select p).ToList();
                %>
                <%if (this.count > 0)
                  { %>
                <div class="w3-col l7 w3-padding-left">
                    <div id="myCarousel" class="carousel slide w3-margin-bottom w3-display-container" data-ride="carousel">
                        <!-- Indicators -->
                        <ol class="carousel-indicators w3-hide-small w3-hide-medium">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <%for (int i = 1; i < this.count; i++)
                              { %>
                            <li data-target="#myCarousel" data-slide-to="<%=i %>"></li>
                            <%} %>
                        </ol>
                        <!-- Wrapper for slides -->
                        <div class="carousel-inner news-small-slide" role="listbox">
                            <%var get_list_first = new TblNewsController().FetchAll().Where(x => x.NewsId == list[0]).Single(); %>
                            <div class="item active w3-display-container">
                                <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list_first.NewsTitle)) %>-<%=get_list_first.NewsId %>">
                                    <img src="/Content/newsdata/avatar/<%=get_list_first.NewsImages %>" alt="slide image" class="news-categories-slide-img" /></a>
                                <div class="carousel-caption w3-display-bottommiddle">
                                    <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list_first.NewsTitle)) %>-<%=get_list_first.NewsId %>" class="w3-large w3-hide-small"><%=get_list_first.NewsTitle %></a>
                                    <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list_first.NewsTitle)) %>-<%=get_list_first.NewsId %>" class="w3-hide-large w3-hide-medium"><%=get_list_first.NewsTitle %></a>
                                </div>
                            </div>
                            <%for (int i = 1; i < this.count; i++)
                              {
                                  var get_list = new TblNewsController().FetchAll().Where(x => x.NewsId == list[i]).Single();
                            %>
                            <div class="item w3-display-container">
                                <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list.NewsTitle)) %>-<%=get_list.NewsId %>">
                                    <img src="/Content/newsdata/avatar/<%=get_list.NewsImages %>" alt="slide image" class="news-categories-slide-img" /></a>
                                <div class="carousel-caption w3-display-bottommiddle">
                                    <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list.NewsTitle)) %>-<%=get_list.NewsId %>" class="w3-large w3-hide-small"><%=get_list.NewsTitle %></a>
                                    <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_list.NewsTitle)) %>-<%=get_list.NewsId %>" class="w3-hide-large w3-hide-medium"><%=get_list.NewsTitle %></a>
                                </div>
                            </div>
                            <%} %>
                        </div>

                        <!-- Left and right controls -->
                        <div class="w3-display-middle">
                            <a class="left carousel-control w3-xxxlarge w3-hide-small" href="#myCarousel" role="button" data-slide="prev">
                                <i class="slide-btn fa fa-angle-left" aria-hidden="true"></i>
                                <span class="sr-only">Previous</span>
                            </a>
                            <a class="right carousel-control w3-xxxlarge w3-hide-small" href="#myCarousel" role="button" data-slide="next">
                                <i class="slide-btn fa fa-angle-right" aria-hidden="true"></i>
                                <span class="sr-only">Next</span>
                            </a>
                            <a class="left carousel-control w3-xxlarge w3-hide-medium w3-hide-large" href="#myCarousel" role="button" data-slide="prev">
                                <i class="slide-btn fa fa-angle-left" aria-hidden="true"></i>
                                <span class="sr-only">Previous</span>
                            </a>
                            <a class="right carousel-control w3-xxlarge w3-hide-medium w3-hide-large" href="#myCarousel" role="button" data-slide="next">
                                <i class="slide-btn fa fa-angle-right" aria-hidden="true"></i>
                                <span class="sr-only">Next</span>
                            </a>
                        </div>
                    </div>
                    <div class="w3-row w3-margin-bottom">
                        <header class="news-cate-header w3-border-teal"><a href="#" class="w3-btn w3-teal"><%=CateName %></a></header>
                        <div class="w3-row">
                            <%var get_news = (from p in new TblNewsController().FetchAll().Where(x => x.NewsDelete == false && x.NewsActive == true && x.NewsCategory == this.cate) orderby p.NewsDate descending select p).Skip(10 * (this.page - 1)).Take(10).ToList();
                              for (int i = 0; i < get_news.Count; i++)
                              {
                                  string time = DateTime.Parse(get_news[i].NewsDate.ToString()).Day.ToString() + "/" + DateTime.Parse(get_news[i].NewsDate.ToString()).Month.ToString() + "/" + DateTime.Parse(get_news[i].NewsDate.ToString()).Year.ToString();
                            %>
                            <div class="news-post w3-margin-top w3-half w3-padding-right w3-center">
                                <a href="../bai-viet/<%=convertToUrl(convertToUnSign(get_news[i].NewsTitle)) %>-<%=get_news[i].NewsId %>">
                                    <img src="/Content/newsdata/avatar/<%=get_news[i].NewsImages %>" /></a>
                                <div class="news-hot-title"><a class="w3-hover-text-teal" href="../bai-viet/<%=convertToUrl(convertToUnSign(get_news[i].NewsTitle)) %>-<%=get_news[i].NewsId %>"><%=limitTitle(get_news[i].NewsTitle) %></a></div>
                                <div class="w3-small"><span class="w3-text-grey"><%=time %></span><span> - </span><span class="w3-text-teal"><%=get_news[i].NewsViewed %> lượt xem</span></div>
                            </div>
                            <%} %>
                        </div>
                        <%var get_all_news = new TblNewsController().FetchAll().Where(x => x.NewsDelete == false && x.NewsActive == true && x.NewsCategory == this.cate).ToList();
                          if (get_all_news.Count != 0)
                          {
                              int all_page = 0;
                              if (get_all_news.Count % 3 != 0)
                                  all_page = get_all_news.Count / 10 + 1;
                              else
                                  all_page = get_all_news.Count / 10;
                              if (all_page > 1)
                              {
                        %>
                        <div class="w3-center w3-margin-top">
                            <ul class="w3-pagination">
                                <%if (this.page > 1)
                                  { %>
                                <li><a href="?page=<%=this.page - 1%>" class="hvr-reveal w3-hover-white"><i class="fa fa-angle-left"></i></a></li>
                                <%} %>
                                <%for (int i = 1; i <= all_page; i++)
                                  { %>
                                <%if (i == this.page)
                                  { %>
                                <li><a class="w3-teal hvr-reveal w3-hover-white" href="javascrit:;"><%=i%></a></li>
                                <%}
                                  else
                                  { %>
                                <li><a href="<%=this.url%>-<%=this.cate%>?page=<%=i%>" class="hvr-reveal w3-hover-white"><%=i%></a></li>
                                <%} %>
                                <%} %>
                                <%if (this.page < all_page)
                                  { %>
                                <li><a href="?page=<%=this.page + 1%>" class="hvr-reveal w3-hover-white"><i class="fa fa-angle-right"></i></a></li>
                                <%} %>
                            </ul>
                        </div>
                        <%}
                          } %>
                    </div>
                </div>
                <%}
                  else
                  {
                %>
                <div class="w3-col l7 w3-padding-left">
                    <p class="w3-large w3-text-red w3-center">Tạm thời chưa có bài viết nào để hiển thị. Các bạn vui lòng quay lại sau<br /> <a class="w3-text-teal" href="../trang-chu">Click vào đây để quay trờ lại trang chủ</a></p>
                </div>
                <%} %>
                
                <div class="w3-quarter w3-padding-left">
                    <uc1:Right_newestpost runat="server" ID="Right_newestpost" />
                    <uc1:Right_hotestpost runat="server" ID="Right_hotestpost" />
                </div>
            </div>
        </div>
    </div>
    <script src="../Scripts/javacuatui5.js"></script>
    <script src="../Scripts/slideup_news.js"></script>
</asp:Content>
